#include <iostream>
#include <vector>
#include <cmath>
#include <fstream>

using namespace std;

int getLog(int N) {
	int log = 0;
    size_t lN = 1;
    while (lN <= N) {
        lN <<= 1;
        ++log;
    }
	return --log;
}

void RMQ(vector<double> & a, vector< vector<double> >& matrix, int N)
{
    int log = getLog(N) + 1;
    matrix.resize(N);
    for (int i = 0; i < N; ++i) {
        matrix[i].resize(log);
        matrix[i][0] = i;
    }

    for (int i = 1; i < log; ++i)
        for (int j = 0; j < N - (1 << i) + 1; ++j)
            matrix[j][i] = a[ matrix[j][i - 1] ] < a[ matrix[j + (1 << (i - 1))][i - 1] ] ? matrix[j][i - 1] : matrix[j + (1 << (i - 1))][i - 1];
}

int main()
{
    ifstream ifile("in.txt");
    int N;
    ifile >> N;
    vector<double> a(N);
    for (int i = 0; i < N; ++i)  
        ifile >> a[i];
    vector< vector<double> > matrix;
    RMQ(a, matrix, N);
    int M, i, j;
    ifile >> M;
    for (int l = 0; l < M; ++l) {
        ifile >> i >> j;
        --j;
        int log = getLog(j - i + 1);
        cout << min( a[matrix[i][log]], a[matrix[j - (1 << log) + 1][log]]) << endl;
    }
    ifile.close();
    return 0;
}